<template>
    <div>
        <van-field v-model="form.username" label='用户名' />
            <van-field v-model="form.password" label='密码' />   
            <van-button color="linear-gradient(to right, #ff6034,#7232dd)" @click="add">
                登录
            </van-button> 
    </div>
</template>

<script>
    export default {
        data(){
            return{
                form:{}
            }
        },
        methods:{
            add(){
                this.$axios.post('article/login',this.form).then(res=>{
                    if(res.data.code==200){
                        alert('登陆成功')
                        localStorage.setItem('userid',res.data.userid)
                        this.$router.push('article')
                    }else{
                        alert(res.data.mes)
                    }
                })
            }
        }
    }
</script>

<style scoped>

</style>